G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
+static gboolean
+gdk_mir_gl_context_realize (GdkGLContext *context,
+ GError **error)
+{
+ GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
+ GdkDisplay *display = gdk_gl_context_get_display (context);
+ GdkGLContext *share = gdk_gl_context_get_shared_context (context);
+ GdkGLProfile profile = gdk_gl_context_get_profile (context);
+ EGLContext ctx;
+ EGLint context_attribs[3];
+ int i;
+
+ if (!_gdk_mir_display_init_egl_display (display))
+ {
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("No GL implementation is available"));
+ return FALSE;
+ }
+
+ i = 0;
+ if (profile == GDK_GL_PROFILE_3_2_CORE)
+ {
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+ }
+ context_attribs[i++] = EGL_NONE;
+
+ ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
+ context_mir->egl_config,
+ share != NULL ? GDK_MIR_GL_CONTEXT (share)->egl_context
+ : EGL_NO_CONTEXT,
+ context_attribs);
+ if (ctx == NULL)
+ {
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_NOT_AVAILABLE,
+ _("Unable to create a GL context"));
+ return FALSE;
+ }
+
+ GDK_NOTE (OPENGL, g_print ("Created EGL context[%p]\n", ctx));
+
+ context_mir->egl_context = ctx;
+
+ return TRUE;
+}
+
static void
gdk_mir_gl_context_end_frame (GdkGLContext *context,
cairo_region_t *painted,
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ context_class->realize = gdk_mir_gl_context_realize;
context_class->end_frame = gdk_mir_gl_context_end_frame;
gobject_class->dispose = gdk_mir_gl_context_dispose;
}
{
GdkDisplay *display = gdk_window_get_display (window);
GdkMirGLContext *context;
- EGLContext ctx;
EGLConfig config;
- int i;
- EGLint context_attribs[3];
if (!_gdk_mir_display_init_egl_display (display))
{
if (!find_eglconfig_for_window (window, &config, error))
return NULL;
- i = 0;
- if (profile == GDK_GL_PROFILE_3_2_CORE)
- {
- context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
- }
- context_attribs[i++] = EGL_NONE;
-
- ctx = eglCreateContext (_gdk_mir_display_get_egl_display (display),
- config,
- share ? GDK_MIR_GL_CONTEXT (share)->egl_context : EGL_NO_CONTEXT,
- context_attribs);
- if (ctx == NULL)
- {
- g_set_error_literal (error, GDK_GL_ERROR,
- GDK_GL_ERROR_NOT_AVAILABLE,
- _("Unable to create a GL context"));
- return NULL;
- }
-
- GDK_NOTE (OPENGL,
- g_print ("Created EGL context[%p]\n", ctx));
-
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
"display", display,
"window", window,
NULL);
context->egl_config = config;
- context->egl_context = ctx;
context->is_attached = attached;
return GDK_GL_CONTEXT (context);